package com.louis.resourceloaderaware;


import com.louis.di.ResourceBean;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ResourceLoader;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

/**
 * @author XRY
 * @date 2023年06月29日7:46
 */
@SpringJUnitConfig(name = "classpath:bean-di.xml")
public class TestAware {
    @Autowired
    private ResourceBean resourceBean;
    @Test
    public void testResource(){
        resourceBean.parse();
    }



    @Test
    public void testAware(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean.xml");
        TestResourceLoaderAware loaderAware = applicationContext.getBean("testResourceLoaderAware", TestResourceLoaderAware.class);
        ResourceLoader resourceLoader = loaderAware.getResourceLoader();
        System.out.println(resourceLoader == applicationContext);
        /*true*/
    }
}
